#include <stdio.h>
#include <stdbool.h>

char* reverseVowels(char* s) {
    char *pStart;
	char *pLast;
	bool bRight, bLeft;
	char tmpChar;
	
	pStart = s;
	pLast = s;
	for(;*pLast != '\0'; pLast++);
	
	while(pStart != pLast)
	{
		switch(*pStart)
		{
			case 'a':
			case 'e':
			case 'i':
			case 'o':
			case 'u':
			case 'A':
			case 'E':
			case 'I':
			case 'O':
			case 'U':
				bLeft = true;
				break;
			default:
				bLeft = false;
				break;
		}
		switch(*pLast)
		{
			case 'a':
			case 'e':
			case 'i':
			case 'o':
			case 'u':
			case 'A':
			case 'E':
			case 'I':
			case 'O':
			case 'U':
				bRight = true;
				break;
			default:
				bRight = false;
				break;
		}

		if(bLeft)
		{
			if(bRight)
			{
				if(*pLast != *pStart)
				{
					tmpChar = *pLast;
					*pLast = *pStart;
					*pStart = tmpChar;
				}
				pStart++;
				if(pStart != pLast)
					pLast--;
			}
			else
			{
				pLast--;
			}
		}
		else
		{
			pStart++;
		}
		
	}
	pStart = s;
	
	return pStart;
}

int main(void)
{
	char str[] = "A man a plan a cameo Zena";
	
	printf("%s\n", reverseVowels(str));
	return 0;
}